//
//  MineWalletCardListCell.m
//  copyrightTrading
//
//  Created by edz on 2020/10/23.
//  Copyright © 2020 郭子一. All rights reserved.
//

#import "MineWalletCardListCell.h"

@interface MineWalletCardListCell ()

@property (nonatomic, strong) UILabel *bankNameLabel;
@property (nonatomic, strong) UILabel *cardNumLabel;
@end

@implementation MineWalletCardListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    UIView *bgView = [UIView new];
    bgView.backgroundColor = RGB_VALUE(0xC4A592);
    bgView.layer.masksToBounds = YES;
    bgView.layer.cornerRadius = 12;
    [self.contentView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.offset(16);
        make.bottom.offset(0);
        make.right.offset(-16);
    }];
    
    self.bankNameLabel = [[UILabel alloc] init];
    self.bankNameLabel.font = JSS_MEDIUM_FONT(13);
    self.bankNameLabel.textColor = RGB_VALUE(0xFFFFFF);
    self.bankNameLabel.text = @"银行卡名称";
    [bgView addSubview:self.bankNameLabel];
    [self.bankNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-15);
        make.top.offset(15);
        make.height.mas_equalTo(18);
        make.left.offset(17);
    }];
    
    self.cardNumLabel = [[UILabel alloc] init];
    self.cardNumLabel.font = JSS_MEDIUM_FONT(36);
    self.cardNumLabel.textColor = RGB_VALUE(0xFFFFFF);
    [bgView addSubview:self.cardNumLabel];
    [self.cardNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-17);
        make.top.equalTo(self.bankNameLabel.mas_bottom).offset(16);
        make.height.mas_equalTo(43);
        make.left.offset(17);
    }];
}

- (void)setDataDic:(NSDictionary *)dataDic
{
    _dataDic = dataDic;
    self.cardNumLabel.text = [self returnBankCard:@"1234567898768909"];
}

-(NSString *)returnBankCard:(NSString *)BankCardStr
{
    NSString *formerStr = [BankCardStr substringToIndex:BankCardStr.length-4];
//    NSString *str1 = [BankCardStr stringByReplacingOccurrencesOfString:formerStr withString:@""];
    NSString *endStr = [BankCardStr substringFromIndex:BankCardStr.length-4];
//    NSString *str2 = [str1 stringByReplacingOccurrencesOfString:endStr withString:@""];
    NSString *middleStr = [formerStr stringByReplacingOccurrencesOfString:formerStr withString:@"**** **** ****"];
    NSString *CardNumberStr = [@"" stringByAppendingFormat:@"%@%@",middleStr,endStr];
    return CardNumberStr;
}
@end
